package org.ecbox.sdk.request;

import org.ecbox.sdk.ApiRuleException;
import org.ecbox.sdk.EopHashMap;
import org.ecbox.sdk.EopRequest;
import org.ecbox.sdk.internal.util.StringUtils;
import org.ecbox.sdk.response.KeyLoginResponse;

/**
 * 密钥登录请求
 * 
 * File: KeyLoginRequest.java<br/>
 * Description: <br/>
 * 
 * Copyright: Copyright (c) 2012 ecbox.com<br/>
 * Company: ECBOX,Inc.<br/>
 * 
 * @author chenxiaochun
 * @date 2014年5月26日
 * @version 1.0
 */
public class KeyLoginRequest extends EopRequest<KeyLoginResponse> {

  private String key;

  public String getKey() {
    return key;
  }

  public void setKey(String key) {
    this.key = key;
  }

  @Override
  public String getApiMethodName() {
    return "ecbox.key.login";
  }

  @Override
  public EopHashMap getTextParams() {
    EopHashMap params = new EopHashMap();
    params.put("key", key);
    return params;
  }

  @Override
  public Class<KeyLoginResponse> getResponseClass() {
    return KeyLoginResponse.class;
  }

  @Override
  public void check() throws ApiRuleException {
    if (StringUtils.isEmpty(key)) {
      throw new ApiRuleException("401", "密钥不能为空");
    }
  }

}
